<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <script src="./js/jquery.js"></script>
    <style>
      * {
        margin: 0;
        padding: 0;
      }
      body {
        height: 1200px;
      }
      .box {
        width: 200px;
        height: 200px;
        background-color: rgb(49, 8, 235);
        overflow: hidden;
        position: relative;
      }
      .son {
        width: 100px;
        height: 100px;
        background-color: rgb(230, 72, 190);
        margin-top: 50px;
        margin-left: 10px;
      }
      button {
        margin-top: 100px;
      }
    </style>
  </head>
  <body>
    <div class="box">
      <div class="son"></div>
    </div>
    <button>获取box位置</button>
    <script>
      $(window).scroll(function () {
        var scrollPosition = $(this).scrollTop(); // 获取滚动条的位置
        console.log("滚动条位置: " + scrollPosition);
      });
    </script>
  </body>
</html>
